package com.lcsolute.admin.controller;

import com.lcsolute.token.domain.entity.User;
import org.springframework.web.bind.annotation.RestController;

import com.lcsolute.token.domain.ResponseResult;
import com.lcsolute.admin.service.LoginService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;


@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user) {
        return loginService.login(user);
    }

    @PreAuthorize("hasAuthority('system:test:list')")
    @RequestMapping("/hello")
    public String hello() {
        System.out.println("hello");
        return "hello";
    }    

    @RequestMapping("/logout")
    public ResponseResult logout() {
        return loginService.logout();
    }
}